package com.gw.ycny.common;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@Api("返回结果")
public class SysResult {
    @ApiModelProperty("状态码")
    private Integer status; //200业务成功 201业务失败
    @ApiModelProperty("返回消息")
    private String msg;     //服务器提示信息
    @ApiModelProperty("返回结果")
    private Object result;    //封装后台返回值
    @ApiModelProperty("状态消息")
    private Object total;   //总条数

    public static SysResult fail(){
        return new SysResult(201,"fail",null,null);
    }

    public static SysResult fail(String msg){
        return new SysResult(201,msg,null,null);
    }

    public static SysResult success(){
        return new SysResult(200,"success", null,null);
    }

    //服务器返回值业务数据
    public static SysResult success(Object result,Object total){
        return new SysResult(200,"success", result,total);
    }

    public static SysResult success(String msg,Object result,Object total){

        return new SysResult(200,msg,result,total);
    }
    public static SysResult success(Object result){
        return new SysResult(200,"success", result,null);
    }

}
